package com.library.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.library.bean.Book;
import com.library.service.BookService;
import com.library.service.impl.BookServiceImpl;


@WebServlet("/updateBook.do")
public class UpdateBookServlet extends HttpServlet {
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		int bookId = Integer.parseInt(request.getParameter("bookId"));
		String bookName = request.getParameter("bookName");
		String bookWriter =  request.getParameter("bookWriter");
		int bookNum = Integer.parseInt(request.getParameter("bookNum"));
		BookService bs = new BookServiceImpl();
		bs.updateBook(new Book(bookId, bookName, bookWriter, bookNum));
		response.sendRedirect("success.jsp");
		
	}
	
	
	
}
